﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using WpfAdvControls.StatusPanel;

namespace WpfAdvControls.Component
{
    /// <summary>
    ///     Interaction logic for MinComponentBar.xaml
    /// </summary>
    public partial class MinComponentBar : UserControl
    {
        private IMinComponent minComponent;

        public MinComponentBar()
        {
            InitializeComponent();
        }

        public MinComponentBar(IMinComponent minComponent) : this()
        {
            SetMinComponent(minComponent);
        }

        public void SetMinComponent(IMinComponent minComponent)
        {
            this.minComponent = minComponent;
            statusBox.SetBinding(StatusBox.StatusProperty,
                new Binding("IsError")
                {
                    Mode = BindingMode.OneWay,
                    Source = minComponent,
                    Converter = new NegativeBoolConverter()
                });
        }

        private void settings_Click(object sender, RoutedEventArgs e)
        {
            var w = Window.GetWindow(Parent);
            minComponent.OnSettingsView(w);
        }
    }
}